<?php

/**
 * This is the model class for table "menu".
 *
 * The followings are the available columns in table 'menu':
 * @property string $id
 * @property string $type_id
 * @property integer $parent_id
 * @property string $alias
 * @property string $name
 * @property string $url
 * @property string $weight
 * @property string $level
 * @property integer $status
 * @property string $create_time
 * @property string $update_time
 * @property string $visibleExpression
 */
class MenuBase extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return MenuBase the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'menu';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('type_id, alias, name', 'required'),
			array('parent_id, status', 'numerical', 'integerOnly'=>true),
			array('type_id', 'length', 'max'=>10),
			array('alias, name', 'length', 'max'=>64),
			array('url', 'length', 'max'=>128),
			array('weight', 'length', 'max'=>11),
			array('level, visibleExpression', 'length', 'max'=>155),
			array('create_time, update_time', 'safe'),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('id, type_id, parent_id, alias, name, url, weight, level, status, create_time, update_time, visibleExpression', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id' => 'ID',
			'type_id' => 'Type',
			'parent_id' => 'Parent',
			'alias' => 'Alias',
			'name' => 'Name',
			'url' => 'Url',
			'weight' => 'Weight',
			'level' => 'Level',
			'status' => 'Status',
			'create_time' => 'Create Time',
			'update_time' => 'Update Time',
			'visibleExpression' => 'Visible Expression',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id,true);
		$criteria->compare('type_id',$this->type_id,true);
		$criteria->compare('parent_id',$this->parent_id);
		$criteria->compare('alias',$this->alias,true);
		$criteria->compare('name',$this->name,true);
		$criteria->compare('url',$this->url,true);
		$criteria->compare('weight',$this->weight,true);
		$criteria->compare('level',$this->level,true);
		$criteria->compare('status',$this->status);
		$criteria->compare('create_time',$this->create_time,true);
		$criteria->compare('update_time',$this->update_time,true);
		$criteria->compare('visibleExpression',$this->visibleExpression,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}